package com.woniuxy.controller;

import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.entity.TestBank;
import com.woniuxy.entity.TestBankType;
import com.woniuxy.service.TestBankTypeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TestBankType)表题库分类控制层
 *
 * @author zjx
 * @since 2021-05-14 19:42:03
 */
@RestController
@RequestMapping("testBankType")
public class TestBankTypeController {
    /**
     * 服务对象
     */
    @Resource
    private TestBankTypeService testBankTypeService;


    @GetMapping("selectAll")
    @ApiOperation("查询所有题库类型")
    public ResponseEntity selectAll(){
        List<TestBankType> list = this.testBankTypeService.queryAll();
        return new ResponseEntity(200,"OK",list);
    }
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public TestBankType selectOne(Integer id) {
        return this.testBankTypeService.queryById(id);
    }

    /**
     * Description : 插入一条数据
     * ChangeLog : 1. 创建 (2021/5/15 15:21 [zjx]);
     * @param testBankType
     * @return null
    */
    @ApiOperation("插入一条数据")
    @PostMapping("/insert")
    public ResponseEntity insert(TestBankType testBankType){
        return new ResponseEntity(200,"OK",this.testBankTypeService.insert(testBankType));
    }

    /**
     * Description : 更新一条数据
     * ChangeLog : 1. 创建 (2021/5/15 15:22 [zjx]);
     * @param testBankType
     * @return null
    */
    @RequestMapping("/update")
    public TestBankType update(TestBankType testBankType){
        return this.testBankTypeService.update(testBankType);
    }

    /**
     * Description : 根据主键删除一条数据
     * ChangeLog : 1. 创建 (2021/5/15 15:27 [zjx]);
     * @param id
     * @return null
    */
    @RequestMapping("/deleteById")
    public boolean deleteById(Integer id){
        return this.testBankTypeService.deleteById(id);
    }

}
